package homework03;

/**
 * @Description: 编写普通通话类实现通话类，该类继承了抽象类并且实现通话接口
 * @author: shenbing.wang@hand-china
 * @date: 2021年06月09日 15:14
 */
public class Code0203CallPackage extends Code0203Abstract implements Code0203CallInterface{
    private int message;

    Code0203Consumption code = new Code0203Consumption();
    /**
     *  expenses    资费
     *  quantity    赠送通话时间
     *  message     赠送短信
     */

    public Code0203CallPackage() {
    }

    public Code0203CallPackage(int expenses, int quantity, int message) {
        super(expenses, quantity);
        this.message = message;
    }

    public int getMessage() {
        return message;
    }

    public void setMessage(int message) {
        this.message = message;
    }

    //  通话类：打印套餐情况重写通话接口，打印继承下来的抽象成员Expenses/quantity/以及自身的成员message
    @Override
    public void show() {
        System.out.printf("通讯套餐：国内语音%d元/分钟，赠送%d分钟国内语音，赠送国内短彩信%d条，包含国内接听来电显示。",getExpenses(),getQuantity(),getMessage());
    }

    //  重写通话服务接口方法　重写接口抽象方法，计算传入进来的时间并把时间和对象传回code类的countCalltime方法中
    @Override
    public void callPackage(int callTime,Code0203PhoneCard code0203PhoneCard) {
        if (getQuantity() == 0){
            setQuantity(1);
        }
        code.countCallTime(callTime,getQuantity(),code0203PhoneCard);
    }
}
